<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserStatusTable extends Migration
{

    protected $tableName = 'user_status';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->unique()->comment('用户ID');
            $table->unsignedTinyInteger('current_level')->default(0)->comment('当前等级');
            $table->unsignedTinyInteger('test_level')->default(0)->comment('评测等级');
            $table->unsignedInteger('word_count')->default(0)->comment('累计阅读量');
            $table->unsignedInteger('lesson_count')->default(0)->comment('课程学习数');
            $table->unsignedInteger('dub_count')->default(0)->comment('跟读次数');
            $table->dateTime('start_study_time')->nullable()->comment('开始学习时间');

            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("ALTER TABLE `$this->tableName` comment '用户学习状态'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
